﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Reflection;

namespace FileChat
{
    class Util
    {
        /// <summary>
        /// 从XML中读取用户清单
        /// </summary>
        /// <param name="root"></param>
        /// <returns></returns>
        public static List<User> GetUserList(XmlNode root)
        {
            List<User> userList = new List<User>();
            foreach (XmlElement usernode in root.ChildNodes)
            {
                User u = new User();
                foreach (PropertyInfo pi in u.GetType().GetProperties())
                {
                    pi.SetValue(u, usernode.Attributes[pi.Name].Value, null);
                }
                userList.Add(u);
            }
            return userList;
        }
    }
}
